<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="apple-touch-icon-precomposed" href="../images/apple-touch-icon.png">
    <title>calendar</title>
    <link rel="stylesheet" href="../../dist/seedsui.min.css">
</head>

<body ontouchstart="">
	<header>
        <div class="titlebar">
            <a class="titlebar-button" href="javascript:back()">
                <i class="icon icon-arrowleft"></i>
            </a>
            <h1 class="titlebar-title">日历</h1>
        </div>
    </header>
	<article>
		<div class="calendar" id="ID-Calendar"></div>
        <a style="margin:8px" class="button block bg-6" id="ID-Show">显示日历</a>
        <a style="margin:8px" class="button block bg-5" id="ID-Hide">隐藏日历</a>
		<a style="margin:8px" class="button block bg-1" id="ID-Month">月</a>
		<a style="margin:8px" class="button block bg-2" id="ID-Week">周</a>
		<a style="margin:8px" class="button block bg-3" id="ID-Today">今天</a>
        <a style="margin:8px" class="button block bg-4" id="ID-Reset">重置</a>
	</article>
    <script src="../../dist/seedsui.min.js"></script>
    <!--Exmobi能力-->
    <!--<script src="../scripts/lib/exmobi/exmobi.js"></script>-->
	<script>
        var view={
            /*=========================
              Model
              ===========================*/
            render:function(){
                var self = this;
                //日历
                this.calendar=new Calendar("#ID-Calendar",{
                    viewType:"week",
                    isShowDayNum:true,
                    disableBeforeDate:new Date(),
                    //isYTouch:false,//是否允许竖向滑动
                    activeDate:new Date(),
                    prevHTML:'<i class="icon-arrowleft"></i>',
                    nextHTML:'<i class="icon-arrowright"></i>',
                    onChange:function(e){
                        console.log(e.activeDate);
                    },
                    onVerticalTransitionEnd:function(e){
                        console.log("拖动方向:"+e.vertical);
                        console.log("高度:"+e.container.clientHeight);
                    },
                });
                //加载数据
                this.loadData();
            },
            refresh:function(){
                console.log("刷新");
            },
            destroy:function(){
                console.log("移除");
            },
            loadData:function(){

                this._attach();//使用backbone时，此行无用
            },
            /*=========================
              Events
              ===========================*/
            _attach:function(e){
                var self=this;

                this.btnMonth=document.getElementById("ID-Month");
                this.btnWeek=document.getElementById("ID-Week");
                this.btnToday=document.getElementById("ID-Today");
                this.btnReset=document.getElementById("ID-Reset");
                this.btnShow=document.getElementById("ID-Show");
                this.btnHide=document.getElementById("ID-Hide");
                this.divCalendar=document.getElementById("ID-Calendar");

                this.btnMonth.onclick=function(){
                    self.calendar.showMonth();
                }
                this.btnWeek.onclick=function(){
                    self.calendar.showWeek();
                }
                this.btnToday.onclick=function(){
                    self.calendar.showToday();
                }
                this.btnReset.onclick=function(){
                    self.calendar.reset();
                }
                this.btnShow.onclick=function(){
                    self.calendar.container.style.display="block";
                    //self.calendar.updateContainerSize();
                    self.calendar.draw();
                }
                this.btnHide.onclick=function(){
                    self.calendar.container.style.display="none";
                }
            },
            /*=========================
              Event Handler
              ===========================*/
        }

        window.addEventListener("load",function(){
            view.render();
        }, false);

        //定义exmobi返回
        function back(){history.go(-1);}
	</script>
</body>
</html>